package com.liuwang.meal.util;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

public class SharedPrefer {

	public static void SaveTableNo(Context context, int tableno) throws Exception {
		SharedPreferences sp = context.getSharedPreferences("tableno",
				Context.MODE_PRIVATE);
		Editor editor = sp.edit();
		editor.putInt("tableno", tableno);
		editor.commit();
	}

	public static int ReadTableNo(Context context) {
		SharedPreferences sp = context.getSharedPreferences("tableno",
				Context.MODE_PRIVATE);
		int tableno = sp.getInt("tableno", 0);
		return tableno;

	}
	
	
	public static void SaveEatNum(Context context, int eatNum) throws Exception {
		SharedPreferences sp = context.getSharedPreferences("eatNum",
				Context.MODE_PRIVATE);
		Editor editor = sp.edit();
		editor.putInt("eatNum", eatNum);
		editor.commit();
	}

	public static int ReadEatNum(Context context) {
		SharedPreferences sp = context.getSharedPreferences("eatNum",
				Context.MODE_PRIVATE);
		int eatNum = sp.getInt("eatNum", 0);
		return eatNum;

	}
	
	public static void SaveUserId(Context context, int userid) throws Exception {
		SharedPreferences sp = context.getSharedPreferences("userid",
				Context.MODE_PRIVATE);
		Editor editor = sp.edit();
		editor.putInt("userid", userid);
		editor.commit();
	}

	public static int ReadUserId(Context context) {
		SharedPreferences sp = context.getSharedPreferences("userid",
				Context.MODE_PRIVATE);
		int userid = sp.getInt("userid", 0);
		return userid;

	}
	
	
	public static void SaveSumPrice(Context context, int price) throws Exception {
		SharedPreferences sp = context.getSharedPreferences("price",
				Context.MODE_PRIVATE);
		Editor editor = sp.edit();
		editor.putInt("price", price);
		editor.commit();
	}

	public static int ReadSumPrice(Context context) {
		SharedPreferences sp = context.getSharedPreferences("price",
				Context.MODE_PRIVATE);
		int price = sp.getInt("price", 0);
		return price;

	}

}
